import java.io.*;
import java.util.*;

public class User implements Serializable {

  private String username;
  private String password;
  private String type; // either "member" or "admin"
  private Vector<UserPreferences> preferences; // vector of Preferences objects
  private HashMap<String, Integer> ratings; // keys: restaurant name, values: rating for restaurant

  public User() {
    setUsername(null);
    setPassword(null);
    setType(null);
    setPreferences(null);
    ratings = new HashMap<String, Integer>();
  }

  public User(String uname, String pass, String type) {
    setUsername(uname);
    setPassword(pass);
    setType(type);
    setPreferences(null);
    ratings = new HashMap<String, Integer>();
  }

  public User(String uname, String pass, String type, Vector<UserPreferences> prefs) {
    setUsername(uname);
    setPassword(pass);
    setType(type);
    setPreferences(prefs);
    ratings = new HashMap<String, Integer>();
  }

  public void setUsername(String uname) {username = uname;}
  public String getUsername() {return username;}
  public void setPassword(String pass) {password = pass;}
  public String getPassword() {return password;}
  public void setType(String t) {type = t;}
  public String getType() {return type;}
  public void setPreferences(Vector<UserPreferences> prefs) {preferences = prefs;}
  public Vector<UserPreferences> getPreferences() {return preferences;}
  public void addRating(String restName, int r) {
    ratings.put(restName, new Integer(r));
  }
  public int getRating(String restName) {
    return ratings.get(restName);
  }

  // adds this preferences to the current vector of preferences
  public void addPreferences(UserPreferences prefs) {
    preferences.addElement(prefs);
  }
}

